package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import com.huawei.appmarket.framework.widget.RoundCornerLayout;
import com.huawei.appmarket.service.store.awk.bean.SubstanceListCardBean;
import com.huawei.appmarket.support.video.VideoPlayer;
import o.cgz;
import o.chc;
import o.chy;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.epv;
import o.eqx;
import o.evp.b;
import o.evt;
import o.evx;
import o.ewm.d;
import o.ewm.h;
import o.ewm.j;

public class HorizontalSpecialTopicItemCard extends BaseHorizontalItemCard {
    private static String ˋ = "HorizontalSpecialTopicItemCard";
    private ImageView ʻ;
    private LinearLayout ʼ;
    private LinearLayout ʽ;
    private TextView ˊॱ;
    private OnClickListener ˋॱ;
    private TextView ͺ;
    private ImageView ॱˊ;
    private RoundCornerLayout ॱॱ;
    private VideoPlayer ᐝ;

    public /* synthetic */ CardBean ˌ() {
        return ʼ();
    }

    public HorizontalSpecialTopicItemCard(Context context) {
        super(context);
    }

    public static int ॱॱ() {
        return chc.ॱˋ();
    }

    public cgz ˏ(View view) {
        this.ʽ = (LinearLayout) view.findViewById(j.ʴˊ);
        this.ʼ = (LinearLayout) view.findViewById(j.ॱﹳ);
        this.ˊॱ = (TextView) view.findViewById(j.ˊʻ);
        ˊ((TextView) view.findViewById(j.ˋ));
        this.ॱˊ = (ImageView) view.findViewById(j.ᐣॱ);
        this.ͺ = (TextView) view.findViewById(j.ㆍʼ);
        ʽ(view);
        return this;
    }

    private void ˊ(View view) {
        int ˎ = epv.ˎ(this.ʼॱ, ॱॱ(), chc.ˋ());
        int ʼ = (int) (((float) ˎ) * epv.ʼ());
        if (view instanceof ImageView) {
            view.setLayoutParams(new LayoutParams(ˎ, ʼ));
        } else if (view instanceof VideoPlayer) {
            view.setLayoutParams(new RelativeLayout.LayoutParams(ˎ, ʼ));
        }
        LayoutParams layoutParams = (LayoutParams) this.ʼ.getLayoutParams();
        layoutParams.width = ˎ;
        this.ʼ.setLayoutParams(layoutParams);
    }

    public SubstanceListCardBean ʼ() {
        if (this.ˊᐝ instanceof SubstanceListCardBean) {
            return (SubstanceListCardBean) this.ˊᐝ;
        }
        return null;
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof SubstanceListCardBean) {
            SubstanceListCardBean substanceListCardBean = (SubstanceListCardBean) cardBean;
            this.ˊॱ.setText(substanceListCardBean.ʾॱ());
            ˋ(this.ͺ, substanceListCardBean.ˋʻ());
            if (substanceListCardBean.ٴ() != 0) {
                this.ॱˊ.setVisibility(0);
                eqx.ˎ(this.ॱˊ, substanceListCardBean.ՙ());
                this.ˉ.setText(substanceListCardBean.ߴ());
            } else {
                this.ॱˊ.setVisibility(8);
            }
            if (Logger.ˎ()) {
                Logger.ˏ(ˋ, "bean.getVideoUrl_()=" + substanceListCardBean.ʻˋ());
            }
            int i = j.ʿˈ;
            int i2 = j.ʿʿ;
            String str = (String) this.ʼ.getTag(i);
            String str2 = (String) this.ʼ.getTag(i2);
            if (!dof.ˋ(str) && str.equals(substanceListCardBean.ʻˋ())) {
                return;
            }
            if (dof.ˋ(str2) || !str2.equals(substanceListCardBean.ʻᐝ())) {
                this.ʼ.setTag(i, substanceListCardBean.ʻˋ());
                this.ʼ.setTag(i2, substanceListCardBean.ʻᐝ());
                if (TextUtils.isEmpty(substanceListCardBean.ʻˋ())) {
                    this.ʽ.removeView(this.ॱॱ);
                    this.ॱॱ = null;
                    this.ᐝ = null;
                    ʻ();
                    return;
                }
                this.ʽ.removeView(this.ʻ);
                this.ʻ = null;
                ˋॱ();
            }
        }
    }

    private void ʻ() {
        Context ˋ = ContentManager.getInstant().getContext();
        int dimensionPixelSize = ˋ.getResources().getDimensionPixelSize(d.ॱʽ);
        int dimensionPixelSize2 = ˋ.getResources().getDimensionPixelSize(d.ॱʼ);
        if (this.ʻ == null) {
            this.ʻ = (ImageView) LayoutInflater.from(ˋ).inflate(h.ʿˋ, null);
            this.ʽ.addView(this.ʻ, 0);
            ˊ(this.ʻ);
        }
        if (this.ʻ != null) {
            eqx.ˋ(dimensionPixelSize, dimensionPixelSize2, this.ʻ, ʼ().ʻᐝ());
            this.ʻ.setContentDescription(ʼ().ʾॱ());
            this.ʻ.setOnClickListener(this.ˋॱ);
        }
    }

    private void ˋॱ() {
        Context ˋ = ContentManager.getInstant().getContext();
        int dimensionPixelSize = ˋ.getResources().getDimensionPixelSize(d.ॱʽ);
        int dimensionPixelSize2 = ˋ.getResources().getDimensionPixelSize(d.ॱʼ);
        if (this.ॱॱ == null || this.ᐝ == null) {
            this.ॱॱ = (RoundCornerLayout) LayoutInflater.from(this.ʼॱ).inflate(h.ˇ, null);
            this.ᐝ = (VideoPlayer) this.ॱॱ.findViewById(j.ॱꓸ);
            this.ʽ.addView(this.ॱॱ, 0);
            ˊ(this.ᐝ);
        }
        if (this.ᐝ != null) {
            this.ᐝ.setVideoBaseInfo(new b().ˎ(ʼ().ʽᐝ()).ˊ(ʼ().ʻᐝ()).ˋ(ʼ().ʻˋ()).ˏ(ʼ().ͺˏ()).ॱ(ʼ().u_()).ʼ(ʼ().ᐝʻ()).ᐝ(ʼ().ॱﾟ()).ʻ(evt.ˏ(ʼ().sp_)).ॱॱ(ʼ().ॱـ()).ॱ());
            eqx.ˋ(dimensionPixelSize, dimensionPixelSize2, this.ᐝ.ॱॱ(), ʼ().ʻᐝ());
            this.ᐝ.ॱॱ().setContentDescription(ʼ().ʾॱ());
            this.ᐝ.ॱॱ().setOnClickListener(this.ˋॱ);
        }
    }

    public int ˊ() {
        return h.ʻᐝ;
    }

    public int ˎ() {
        return h.ʻᐝ;
    }

    public void ॱ(final chy o_chy) {
        this.ˋॱ = new evx(this) {
            final /* synthetic */ HorizontalSpecialTopicItemCard ˏ;

            public void ˋ(View view) {
                o_chy.ˏ(0, this.ˏ);
            }
        };
        ˉ().setOnClickListener(this.ˋॱ);
    }

    public void x_() {
        if (this.ˉ != null) {
            this.ˉ.setText(((SubstanceListCardBean) this.ˊᐝ).ʽˊ());
        }
    }
}
